package com.hibernate.account ;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.junit.Test;

import com.hibernate.utils.HibernateUtils;

public class AccountService extends HibernateUtils{
	/**
	 * 说明：
	 * 		accountDao.removeMoney(11L)与accountDao.addMoney(22L)开启了两个session，导致该操作不是处在同一个事务中
	 */
	@Test
	public void testTransform(){
		AccountDao accountDao = new AccountDao();
		accountDao.removeMoney(11L);
		accountDao.addMoney(22L);
	}
	
	@Test
	public void testTransform_Super(){
		Session session = sessionFactory.openSession();
		Transaction transaction = session.beginTransaction();
		AccountDao accountDao = new AccountDao();
		accountDao.removeMoney_Super(11L, session);
		accountDao.addMoney_Super(22L, session);
		transaction.commit();
		session.close();
	}
}
